﻿using System.ComponentModel.DataAnnotations;
using System.Reflection;
using System.Text.Json.Serialization;
using WcMatch.Utility;

namespace WcMatch.Models
{
    public class StudentWithResume
    {
        //public string? CitizenId { get; set; }

        //public string? Name { get; set; }

        //public string? Gender { get; set; }

        //public string? EthnicGroups { get; set; }

        //public string? ProvinceBorn { get; set; }

        //public string? CityBorn { get; set; }

        //[JsonConverter(typeof(DateTimeJsonConverter))]
        //public DateTime? EnrollmentYear { get; set; }

        //[JsonConverter(typeof(DateTimeJsonConverter))]
        //public DateTime? GraduationYear { get; set; }

        //public string? College { get; set; }

        //public string? Major { get; set; }

        //public string? StuId { get; set; }

        //public string? Degree { get; set; }

        //public string? Phone { get; set; }

        //public string? FamilyAddr { get; set; }

        //public string? CompanyName { get; set; }

        //public string? CompanyId { get; set; }

        //[JsonConverter(typeof(DateTimeJsonConverter))]
        //public DateTime? BeginTime { get; set; }

        //[JsonConverter(typeof(DateTimeJsonConverter))]
        //public DateTime? EndTime { get; set; }

        //public string? Job { get; set; }

        //public int? Salary { get; set; }

        ////当前工作状态：在职/离职
        //public string? CurrentJobStatus { get; set; }

        //public string? Others { get; set; }

        //public int? EmploymentType { get; set; }

        //public StudentWithResume(Student stu, StuResume resume)
        //{
        //    PropertyInfo[] pis = this.GetType().GetProperties();
        //    PropertyInfo[] pStu = stu.GetType().GetProperties();
        //    PropertyInfo[] pResume = resume.GetType().GetProperties();

        //    int len = pis.Length;
        //    for (int i = 0; i < len; i++)
        //    {
        //        string pName = pis[i].Name.ToLower();
        //        var pi = pStu.Where(s => s.Name.ToLower() == pName).FirstOrDefault();
        //        if (pi != null) 
        //        {
        //            var pValue = pi.GetValue(stu);
        //            if (pValue != null)
        //                pis[i].SetValue(this, pValue);
        //            else
        //            {
        //                pi = pResume.Where(s => s.Name.ToLower() == pName).FirstOrDefault();
        //                if (pi != null) 
        //                {
        //                    pValue = pi.GetValue(resume);
        //                    pis[i].SetValue(this, pValue); 
        //                }
        //            }
        //        }
        //        else
        //        {
        //            pi = pResume.Where(s => s.Name.ToLower() == pName).FirstOrDefault();
        //            if (pi != null)
        //            {
        //                var pValue = pi.GetValue(resume);
        //                pis[i].SetValue(this, pValue);
        //            }
        //        }
        //    }
        //}
    
        public Student Brief { get; set; }
        public List<StuResume> Resumes { get; set; }

        public StudentWithResume() { 
            Resumes = new List<StuResume> { };
        }
    }
}
